/*!
 *
 *  @author     Jonas Sciangula Street <joni2back@gmail.com>
 *  @package    Dapadarse
 *  @date       2012-11-20
 *
 */
 
jQuery(function() {

    var friends = jQuery('.friends .profile input[type=checkbox]');
    var totalFriends = TOTAL_TARGETS_PER_USER ? TOTAL_TARGETS_PER_USER : 5;
    
    friends.filter(':checked').parents('.profile').toggleClass('active');
    friends.live('change', function() {
        var selecteds = friends.filter(':checked').length >= totalFriends;
        friends.not(":checked").attr("disabled", selecteds);    
        jQuery(this).parents('.profile').toggleClass('active');
    });

    
    jQuery("#view_fans").click(function() {
        jQuery(this).hide(500).parent().find('.list').fadeIn(500);
    });
    
    jQuery("#view_goals").click(function() {
        jQuery(this).hide(500).parent().find('.list').fadeIn(500);
    });
    
    jQuery("#view_friends").click(function() {
        jQuery(this).hide(500).parent().find('.list').fadeIn(500);
    });    
    
    jQuery(".profiles-content.friends .profile img").lazyload({
        effect: 'fadeIn',
        threshold: 20
    });
    
    jQuery("#invite_friends").live('click', function() {
    	FB.ui({	method: 'apprequests',
	    		message: 'Empeza a usar Cita a Ciegas y deja de dar vueltas con esos contactos que te gustan ;)'
	    	  }, function() {
	    		  //otorgarle al flaco mas citas
	    	  });
    });
    
    jQuery("#feed_post").live('click', function() {
    	FB.ui({
	    		method: 'feed',
	    		link: CANVAS_URL,
	    		picture: 'http://example.com/dialog_image.png',
	    		name: 'Testing Action links',
	    		caption: 'Cita a Ciegas',
	    		actions: [{'name': 'get reward', 'link': 'http://example.com/redeem_reward'}],
	            description: 'Action links are awesome.'
    		}, function() {console.log(response);
    	});
    });    
});